package com.example.spring_ioc.Component;


import com.example.spring_ioc.Service.UserService;
import com.example.spring_ioc.model.UserInfo;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
public class UserInfoComponent {
    @Bean // @Bean的使用需要搭配5大注解中的任一一个
    public UserInfo userInfo() {
        return new UserInfo("zhangsan",10);
    }
//    @Primary
    @Bean
    public UserInfo userInfo1() {
        return new UserInfo("lisi",20);
    }
    @Bean
    public UserInfo userInfo3() {
        return new UserInfo("wangwu",30);
    }

//    @Primary
    @Bean
    public String name() {
        return "test";
    }
    @Bean
    public String name2() {
        return "test2";
    }

    @Bean
    public UserInfo userInfo2(@Qualifier("name2") String name3) {
        return new UserInfo(name3,30);
    }

}
